<template>
    <div>
        <!-- 井壁风险结论表 -->
        <a-table :columns="columns" :data-source="props.stabilityData" :pagination="false">
            <template #bodyCell="{ column, text }"> {{ text ? text : '---' }} </template>
        </a-table>
        <a-divider orientation="left">结论</a-divider>
        <a-list size="small">
            <a-list-item>{{ boreholeStabilityOne }}</a-list-item>
            <a-list-item>{{ boreholeStabilityTwo }}</a-list-item>
        </a-list>
    </div>
</template>
<script setup>
import { ref } from 'vue';
const props = defineProps({
    stabilityData: {
        type: Object,
    },
    wallConclusion: {
        type: String,
        default: ''
    }
});
const columns = ref([
    {
        title: "井深（m）",
        dataIndex: "depth",
        key: "depth",
    },
    {
        title: "钻井液临界密度（g/cm3）",
        dataIndex: "rh0",
        key: "rh0",
    },
    {
        title: "扩径最大值（mm）",
        dataIndex: "n",
        key: "n",
    },
    {
        title: "危险等级",
        dataIndex: "is_Not_Safe",
        key: "is_Not_Safe",
    }
])
const boreholeStabilityOne = ref('')
const boreholeStabilityTwo = ref('')
const boreholeStability = ref({
    is_safe: true,
    first_dangerous_depth: 0,
    first_dangerous_N: 0,
    first_dangerous_rho: 0,
    first_dangerous_density: 0,
    max_N: 0,
    max_N_depth: 0
})

// watch(() => props.wallConclusion, (newVal, oldVal) => {
//     console.log('props.wallConclusion', props.wallConclusion);
//     boreholeStability.value = JSON.parse(props.wallConclusion);
//     getConclusion()
// });

// 结论
function getConclusion() {
    // console.log('井壁稳定性', props.stabilityData, props.wallConclusion);
    boreholeStability.value = JSON.parse(props.wallConclusion);
    if (boreholeStability.value.is_safe == true) {
        boreholeStabilityOne.value = '当前钻井液密度符合要求，井壁安全'
    } else {
        boreholeStabilityOne.value = `第一个危险点井深为${boreholeStability.value.first_dangerous_depth}米，
        扩径最大值为${boreholeStability.value.first_dangerous_N}cm，
        其钻井液最小密度应该为${boreholeStability.value.first_dangerous_rho}g/cm^3，
        实际为${boreholeStability.value.first_dangerous_density}g/cm^3`
    }
    boreholeStabilityTwo.value = `井壁发生最大变形处井深为${boreholeStability.value.max_N_depth}m，
    其变形量为${boreholeStability.value.max_N}cm`
}
getConclusion()
</script>